﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Auditoria
{
    public partial class Login : Form
    {
        Conexion conn;

        public Login()
        {
            InitializeComponent();
            
        }
              
        private void btnConectar_Click(object sender, EventArgs e)
        {
            this.Conectar();
        }

        private void Conectar() 
        {
            String user = this.cajaUsuario.Text;
            String pass = this.cajaPass.Text;
            String dbname = this.cajaServidor.Text;
            this.conn = new Conexion(dbname, user, pass);
            int connExitosa = this.conn.EstaConecto();
            if (connExitosa == 0) 
            {
                this.conn.Desconectar();
                Principal nuevo = new Principal(this.conn);
                nuevo.getLogin(this);
                this.Hide();
                nuevo.Show();
            }
            else if (connExitosa == -1)
            {
                MessageBox.Show("Ocurrio un Error en C#, no se puede conectar al Oracle 10g");
            }
            else 
            {
                MessageBox.Show("Ocurrio un Error en Oracle, Codigo Error: "+connExitosa);
            }
        }

        private void lblSalir_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Application.Exit();
        }

        private void btnSalir_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
